Debian 8 Jessie
Sponsored Link

Management tools
2015/05/07
 
Install useful tools for virtual machine management.
[1] Install tools.
root@dlp:~#
aptitude -y install libguestfs-tools virt-top
[2] "ls" a directory in a virtual machine
root@dlp:~#
virt-ls -l -d debian8 /root

total 20
drwx------  2 0 0 4096 May  7 10:22 .
drwxr-xr-x 22 0 0 4096 May  7 10:15 ..
-rw-------  1 0 0  153 May  7 11:44 .bash_history
-rw-r--r--  1 0 0  570 Jan 31  2010 .bashrc
-rw-r--r--  1 0 0  140 Nov 19  2007 .profile
[3] "cat" a file in a virtual machine
root@dlp:~#
virt-cat -d debian8 /etc/passwd

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
...
...
[4] Edit a file in a virtual machine
root@dlp:~#
virt-edit -d debian8 /etc/fstab


# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/debian--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/vda1 during installation
UUID=82c9915f-4b67-46cc-ac63-c6dd4d7662d1 /boot           ext2    defaults        0       2
/dev/mapper/debian--vg-swap_1 none            swap    sw              0       0
[5] Display disk usage in a virtual machine
root@dlp:~#
virt-df -d debian8

Filesystem                           1K-blocks       Used  Available  Use%
debian8:/dev/sda1                       240972      33211     195320   14%
debian8:/dev/debian-vg/root           29284444     958140   26815700    4%
[6] Mount a disk for a virtual machine
root@dlp:~#
guestmount -d debian8 -i /mnt

root@dlp:~#
ll /mnt

total 89
drwxr-xr-x  2 root root  4096 May  7 19:19 bin
drwxr-xr-x  4 root root  1024 May  7 19:20 boot
drwxr-xr-x  4 root root  4096 May  7 19:13 dev
drwxr-xr-x 83 root root  4096 May  7 19:24 etc
drwxr-xr-x  3 root root  4096 May  7 19:20 home
...
...
[7] Display the status of virtual machines
root@dlp:~#
virt-top

virt-top 21:58:43 - x86_64 4/4CPU 2801MHz 12158MB
3 domains, 1 active, 1 running, 0 sleeping, 0 paused, 2 inactive D:0 O:0 X:0
CPU: 0.0%  Mem: 4096 MB (4096 MB by guests)

   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM    TIME   NAME
    6 R                      0.0  0.0   0:04.92 debian8
    -                                           (template)
    -                                           (win2k12R2)
 
Tweet